package org.jvending.provisioning.config.matchers.impl;

public class MatcherTypeHandler extends org.apache.ws.jaxme.impl.JMSAXElementParser {
    /**
     * The current state. The following values are valid states:
     * 0 = Before parsing the element
     * 1 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}attribute-name
     * 2 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}matcher-class
     * 3 = While or after parsing the child element {http://java.sun.com/xml/ns/j2ee-cp}init-param
     */
    private int __state;


    public boolean startElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName, org.xml.sax.Attributes pAttr) throws org.xml.sax.SAXException {
        org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl _1 = getHandler();
        switch (__state) {
            case 0:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "attribute-name".equals(pLocalName)) {
                    __state = 1;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 1:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "matcher-class".equals(pLocalName)) {
                    __state = 2;
                    _1.addSimpleAtomicState();
                    return true;
                }
                break;
            case 2:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "init-param".equals(pLocalName)) {
                    __state = 3;
                    org.apache.ws.jaxme.JMManager _2 = getHandler().getJMUnmarshaller().getJAXBContextImpl().getManagerS(org.jvending.provisioning.config.matchers.InitParam.class);
                    java.lang.Object _3 = _2.getElementS();
                    org.apache.ws.jaxme.impl.JMSAXElementParser _4 = _2.getHandler();
                    _4.init(_1, _3, "http://java.sun.com/xml/ns/j2ee-cp", "init-param", _1.getLevel());
                    _4.setAttributes(pAttr);
                    _1.addElementParser(_4);
                    return true;
                }
                break;
            case 3:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "init-param".equals(pLocalName)) {
                    __state = 3;
                    org.apache.ws.jaxme.JMManager _5 = getHandler().getJMUnmarshaller().getJAXBContextImpl().getManagerS(org.jvending.provisioning.config.matchers.InitParam.class);
                    java.lang.Object _6 = _5.getElementS();
                    org.apache.ws.jaxme.impl.JMSAXElementParser _7 = _5.getHandler();
                    _7.init(_1, _6, "http://java.sun.com/xml/ns/j2ee-cp", "init-param", _1.getLevel());
                    _7.setAttributes(pAttr);
                    _1.addElementParser(_7);
                    return true;
                }
                break;
            default:
                throw new java.lang.IllegalStateException("Invalid state: " + __state);
        }
        return false;
    }

    public void endElement(java.lang.String pNamespaceURI, java.lang.String pLocalName, java.lang.String pQName, java.lang.Object pResult) throws org.xml.sax.SAXException {
        org.jvending.provisioning.config.matchers.MatcherType _1 = (org.jvending.provisioning.config.matchers.MatcherType) result;
        switch (__state) {
            case 1:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "attribute-name".equals(pLocalName)) {
                    _1.setAttributeName((java.lang.String) pResult);
                    return;
                }
                break;
            case 2:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "matcher-class".equals(pLocalName)) {
                    _1.setMatcherClass((java.lang.String) pResult);
                    return;
                }
                break;
            case 3:
                if ("http://java.sun.com/xml/ns/j2ee-cp".equals(pNamespaceURI) && "init-param".equals(pLocalName)) {
                    _1.getInitParam().add(pResult);
                    return;
                }
                break;
            default:
                throw new java.lang.IllegalStateException("Illegal state: " + __state);
        }
    }

    public boolean isFinished() {
        switch (__state) {
            case 3:
            case 2:
                return true;
            default:
                return false;
        }
    }

}
